﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.SheepCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepCommandHandler
{
    public class SheepGetCommandHandler : IRequestHandler<SheepGetCommand, Results<SheepOutPut>>
    {

        private readonly ISheepService sheepService;
        private readonly ILogger<SheepGetCommandHandler> logger;
        public SheepGetCommandHandler(ISheepService sheepService, ILogger<SheepGetCommandHandler> logger)
        {
            this.sheepService = sheepService;
            this.logger = logger;
        }

        /// <summary>
        /// 羊场反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<SheepOutPut>> Handle(SheepGetCommand request, CancellationToken cancellationToken)
        {
            var list = await sheepService.GetSheep(request.Input);
            var results =  Results<SheepOutPut>.DataResult(list);
            return results;
        }







    }




}
